<!DOCTYPE html>
<html lang="zh-CN">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">
    <link rel="stylesheet" href="assets/css/layui.css">
    <link rel="stylesheet" href="assets/css/login.css">
    <link rel="icon" href="/favicon.ico">
    <title>管理后台</title>
</head>
<body class="login-wrap" style="background-image: url(./assets/images/login_back1.jpg); background-size: cover;">
    <div class="login-container">
        <form class="login-form">
            <div class="input-group">
				<span style="font-size: 30px; text-align: center; padding-bottom: 25px;">GTM管理后台</span>
                <input type="text" id="account" class="input-field">
                <label for="username" class="input-label">
                    <span class="label-title">用户名</span>
                </label>
            </div>
            <div class="input-group">
                <input type="password" id="password" class="input-field">
                <label for="password" class="input-label">
                    <span class="label-title">密码</span>
                </label>
            </div>
            <button type="button" class="login-button">登录<i class="ai ai-enter" onclick="login()"></i></button>
        </form>
    </div>
</body>
<script src="assets/layui.js"></script>
<script src="mui.js"></script>
<script src="index.js" data-main="login"></script>
<script type="text/javascript">
	mui.init();
	function login(){
		var Account = document.getElementById("account").value
		var Password = document.getElementById("password").value
		mui.ajax('http://localhost:8080/login',{
			data:{
				account: Account,
				password: Password
			},
			dataType:'json',//服务器返回json格式数据
			type:'post',//HTTP请求类型
			timeout:10000,//超时时间设置为10秒；
			headers:{'Content-Type':'application/json'},
			success:function(data){
				if (data == true){
					alert("登录成功!")
					mui.openWindow({
					  url:'./index.html',					
					  id:'index.html'			
					  });
				}
				else{
					alert("用户名或密码错误，请重新输入")
				}
			},
			error:function(xhr,type,errorThrown){
				alert("登录失败！请重新登录")
			}
		});
	}
</script>
</html>